package com.salmon.common.utils;

import org.springframework.web.context.request.ServletWebRequest;

public class WebUtils {

    /**
     * 判断是否是Ajax请求
     * @param request ServletWebRequest
     * @return 返回true代码是ajax请求，false表示请求是传统的 同步HTTP请求
     */
    public static boolean isAjax(ServletWebRequest request) {
        return request.getHeader("X-Requested-With") != null
                && "XMLHttpRequest".equalsIgnoreCase(request.getHeader("X-Requested-With"));
    }
}
